package com.day06_Collection_test;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * @ClassName: Linklist_demo
 * @Author: 豆豆在睡觉
 * @Create 2024/3/8-20:55
 * @Version 1.0
 */
public class Linklist_demo {
    public static void main(String[] args) {
        LinkedList<Student> linkList = new LinkedList<Student>();
        Student d1 = new Student("zw", 12);
        Student d2 = new Student("zwx,", 23);
        Student d3 = new Student("zz", 13);
        linkList.add(d1);
        linkList.add(d2);
        linkList.add(d3);

        for (int i = 0; i <linkList.size() ; i++) {
            System.out.println(linkList.get(i).getName());
        }
        System.out.println("----");
        for (Student s: linkList) {
            System.out.println(s.getName());
        }
        System.out.println("---");
        Iterator<Student> its = linkList.listIterator();
        while (its.hasNext()) {
            Student s = its.next();
            System.out.println(s.getName());
        }
    }
}
